package com.test.daily.leetcode.y2022.m05.day0528;

import java.util.ArrayDeque;
import java.util.Stack;

/**
 * @descriptions:
 * @author: Tom
 * @date: 2022/5/28 下午 10:31
 * @version: 1.0
 */
public class Solution {
    public String removeOuterParentheses(String s) {
        Stack<Character> stack = new Stack<>();
        StringBuilder stringBuilder = new StringBuilder();
        for (int i = 0; i < s.length(); i++) {
           if(stack.isEmpty()){
              stack.push('(');
           }
           if(!stack.isEmpty()){
               stringBuilder.append(s.charAt(i));
           }
           if(!stack.isEmpty() && s.charAt(i)==')'){
               stack.pop();
           }
        }
        return stringBuilder.toString();
    }
}
